<?
//impostazioni modulo Pagine Web
include("includes/config.inc.php");
include("includes/auth.lib.php");
include("includes/content.class.php");
$module = "PAGINE WEB";
switch($lang) {
  case "ita":
	$currentlang = " - ITA";
  break;

  case "eng":
	$currentlang = " - ENG";
  break;

  case "fra":
	$currentlang = " - FRA";
  break;

  case "esp":
	$currentlang = " - ESP";
  break;
}
$javascript = "function control_topic()  {
					if(document.addtopic.nome.value == '')  {
					 alert('Attenzione! Devi inserire il nome.');
					 return false;
					}   else
					 return true;
}

				function control_topic_s()  {
					if(document.addtopic_s.nome_s.value == '')  {
					 alert('Attenzione! Devi inserire il nome.');
					 return false;
					}   else
					 return true;
}

				function control_page()  {
					if(document.addpageform.titolo.value == '')  {
					 alert('Attenzione! Devi inserire il titolo.');
					 return false;
					}   else
					 return true;
}

";
//$onload = "openHide(addsezione);";
   list($status, $user) = auth_get_status();
   switch($status){
       case AUTH_LOGGED:
// include Editor Start
include("FCKeditor/fckeditor.php");
// include Editor Ende
        $result1 = @mysql_query("SELECT nome,stato FROM utenti WHERE id='$id_user';");
        list($username,$level) = mysql_fetch_row($result1);
            //recupero i dati in post
			 $currentpage = urldecode($_POST['currentpage']);
			 if($currentpage == "")
			  $currentpage = urldecode($_GET['currentpage']);
			 if($currentpage == "")  {
			  $currentpage = $_SERVER['REQUEST_URI'];
			  $start = strlen($_SERVER['SCRIPT_NAME']) - 11;
			  $url = substr($currentpage, $start);
			  //die($currentpage."<br>".$start."<br>".$url);
			  $currentpage = urlencode($url);
			 }  
			$op = $_GET['op'];
			if(!isset($op) || $op == "")
			 $op = $_POST['op'];
			$idtopics = $_GET['idtopic'];
			if(!isset($idtopics) || $idtopics == "")
			 $idtopics = $_POST['idtopic'];
			$nomes = $_POST['nome'];
			if(!isset($nomes) || $nomes == "")
			 $nomes = $_POST['nome_s'];
			$idtopicupd = $_GET['idtopicupd'];
			if(!isset($idtopicupd) || $idtopicupd == "")
			 $idtopicupd = $_POST['idtopicupd'];
			$nomeupd = $_POST['nomeupd'];
         	$idfathers = $_POST['idfather'];
         	$ordines = $_POST['ordine'];
			$idpages = $_GET['idpage'];
			if(!isset($idpages) || $idpages == "")
			 $idpages = $_POST['idpage'];
			$titolos = $_POST['titolo'];
			$contenutos = $_POST['contenuto'];
			$tagtitles = $_POST['tagtitle'];
			$tagkeys = $_POST['tagkey'];
			$metatitles = $_POST['metatitle'];
			$metakeys = $_POST['metakey'];
			$metadescs = $_POST['metadesc'];
			$hiddens = $_POST['hidden'];
			$tagdescs = $_POST['tagdesc'];
			$percorso = $_GET['percorso'];
			if($percorso == "")  {
			  $percorso = $_POST['percorso'];
			} else
			   $percorso = urldecode($percorso);
			$last_folder = "/".substr(strrchr($percorso, "/"), 1);
			$percorso_prec = str_replace($last_folder, "", $percorso); 
			$menusx = "<table width=203 cellpadding=3 border=0><tr><td class=menusx colspan=5><b>Sezioni principali</b></td></tr>\n";
			    $qry_topic = "SELECT idtopic,nome,ordine FROM topics WHERE idfather=0 AND lang='$lang' ORDER BY ordine ASC;";
				$result_topic = mysql_query($qry_topic);
				$num_topic = mysql_num_rows($result_topic);
				$result_max = mysql_query("SELECT MAX(ordine) FROM topics WHERE idfather=0 AND lang='$lang';");
				list($maxordine) = mysql_fetch_row($result_max);
				if($num_topic > 0)  {
			     while(list($idtopic, $nome, $ordine) = mysql_fetch_row($result_topic))  {
				  if($ordine == "0")
				   $up = "&nbsp;";
				  else
				   $up = "<a href=content.php?op=up&idtopic=$idtopic&currentpage=$currentpage&percorso=$percorso><img src=imgs/ico_up.gif width=16 height=16 alt=\"sposta su\" border=0></a>";
				  if($ordine == $maxordine)
				   $down = "&nbsp;";
				  else
				   $down = "<a href=content.php?op=down&idtopic=$idtopic&currentpage=$currentpage&percorso=$percorso><img src=imgs/ico_down.gif width=16 height=16 alt=\"sposta gi�\" border=0></a>";   
				  $menusx .= "<tr><td class=menusx><a class=menusx href=\"content.php?idtopic=$idtopic&op=content&percorso=/".$nome."\">$nome</a></td>
				  <td>$up</td>
				  <td>$down</td>
				  <td><a href=javascript:; onclick=\"showHide('editSezione','$idtopic','$nome');\"><img src=imgs/ico_edit.gif width=16 height=16 alt=\"modifica\" border=0></a></td>
				  <td><a href=\"content.php?op=del&idtopic=$idtopic&currentpage=$currentpage&percorso=$percorso\" onclick=\"return confirm('Sei sicuro di voler eliminare la sezione $nome ?');\"><img src=imgs/ico_delete.gif width=16 height=16 alt=\"elimina\" border=0></a></td>
				  </tr>\n";
				 }
				 $menusx .= "<tr><td colspan=5 class=menusx bgcolor=\"#CCCCCC\"><a class=menusx href=javascript:; onclick=\"showHide('addsezione');\">Aggiungi voce</a></td></tr></table>";
				 $content = "&nbsp;";
				}            
//######################opzioni possibili############################################

            switch ($op)  {
			
			  case "content":
			    $currentTopic = new topic($idtopics);
				if($percorso_prec != "")
				 $opcontent = "&op=content";
				else
				 $opcontent = "";  
			    $content = "<table class=\"content\" width=\"100%\" align=\"left\" cellpadding=\"3\" cellspacing=\"0\" border=0>\n"
                 ."<tr><td align=\"left\" valign=\"top\"><table width=100% cellpadding=2 cellspacing=0 border=0><tr><td class=\"tbtit\" width=16><a href=\"content.php?idtopic=$currentTopic->idfather$opcontent&percorso=$percorso_prec\"><img src=\"imgs/precedente.gif\" width=16 height=16 alt=\"Cartella precedente\" border=0></a></td><td class=tbtit align=left>NavBar : $percorso</td></tr></table></td></tr>\n"
				 ."<tr><td colspan=2><table width=320px class=content cellpadding=3 cellspacing=0 border=0>";
				 //estrazione sottocategorie
				$result_max = mysql_query("SELECT MAX(ordine) FROM topics WHERE idfather='$idtopics';");
				list($maxordine) = mysql_fetch_row($result_max);
				 $qry_cat = "SELECT idtopic,nome,ordine FROM topics WHERE idfather='$idtopics' ORDER BY ordine ASC;";
				 $res_cat = mysql_query($qry_cat);
				 while(list($idtopic,$nome,$ordine) = mysql_fetch_row($res_cat))  {
				  if($ordine == "0")
				   $up = "&nbsp;";
				  else
				   $up = "<a href=\"content.php?op=up&idtopic=$idtopic&currentpage=$currentpage&percorso=$percorso\"><img src=imgs/ico_up.gif width=16 height=16 alt=\"sposta su\" border=0></a>";
				  if($ordine == $maxordine)
				   $down = "&nbsp;";
				  else
				   $down = "<a href=\"content.php?op=down&idtopic=$idtopic&currentpage=$currentpage&percorso=$percorso\"><img src=imgs/ico_down.gif width=16 height=16 alt=\"sposta gi�\" border=0></a>";   
				   $content .= "<tr><td class=content width=20px><a class=content href=\"content.php?idtopic=$idtopic&op=content&percorso=".urlencode($percorso."/".$nome)."\"><img src=\"imgs/folder.gif\" width=20 height=20 alt=\"$nome\" border=0></a></td><td width=200px> <a class=content href=\"content.php?idtopic=$idtopic&op=content&percorso=".urlencode($percorso."/".$nome)."\">$nome</a></td>
				   <td width=20px bgcolor=\"#DFDFDF\">$up</td>
				   <td width=20px bgcolor=\"#DFDFDF\">$down</td>
				   <td width=20px bgcolor=\"#DFDFDF\"><a href=javascript:; onclick=\"showHide('editSezione','$idtopic','$nome');\"><img src=imgs/ico_edit.gif width=16 height=16 alt=\"modifica\" border=0></a></td>
				   <td width=20px bgcolor=\"#DFDFDF\"><a href=\"content.php?op=del&idtopic=$idtopic&currentpage=$currentpage&percorso=".urlencode($percorso)."\" onclick=\"return confirm('Sei sicuro di voler eliminare la sezione $nome ?');\"><img src=imgs/ico_delete.gif width=16 height=16 alt=\"elimina\" border=0></a></td>
				   <td width=20>&nbsp;</td>
				   </tr>";
				 }
				 //estrazione pagine web
				 $qrymax_page = "SELECT MAX(ordine) FROM content WHERE idtopic='$idtopics';";
				 $resultpage_max = mysql_query($qrymax_page);
				 list($maxordinepage) = mysql_fetch_row($resultpage_max);
				 $qry_page = "SELECT idpage,titolo,ordine,pubblica FROM content WHERE idtopic='$idtopics' ORDER BY ordine ASC;";
				 $res_page = mysql_query($qry_page);
				 while(list($idpage, $titolo, $ordinep, $pubblica) = mysql_fetch_row($res_page))  {
				  if($ordinep == "0")
				   $up = "&nbsp;";
				  else
				   $up = "<a href=\"content.php?op=up_page&idpage=$idpage&currentpage=$currentpage&percorso=".urlencode($percorso)."\"><img src=imgs/ico_up.gif width=16 height=16 alt=\"sposta su\" border=0></a>";
				  if($ordinep == $maxordinepage)
				   $down = "&nbsp;";
				  else
				   $down = "<a href=\"content.php?op=down_page&idpage=$idpage&currentpage=$currentpage&percorso=".urlencode($percorso)."\"><img src=imgs/ico_down.gif width=16 height=16 alt=\"sposta gi�\" border=0></a>";
				   $pubblica=="y" ? $linkp = "<a href=\"content.php?op=disattiva&idpage=$idpage&currentpage=$currentpage&percorso=".urlencode($percorso)."\"><img src=imgs/ico_green.jpg width=16 height=16 alt=\"disattiva\" border=0></a>" :
				   $linkp = "<a href=\"content.php?op=pubblica&idpage=$idpage&currentpage=$currentpage&percorso=".urlencode($percorso)."\"><img src=imgs/ico_red.jpg width=16 height=16 alt=\"pubblica\" border=0></a>";   
				   $content .= "<tr><td class=content width=20><img src=\"imgs/page.gif\" width=20 height=20 alt=\"$titolo\"></td><td> $titolo</td>
				   <td width=20px bgcolor=\"#DFDFDF\">$up</td>
				   <td width=20px bgcolor=\"#DFDFDF\">$down</td>
				   <td width=20px bgcolor=\"#DFDFDF\"><a href=\"content.php?idtopic=$idtopics&op=content&percorso=".urlencode($percorso)."&idpage=$idpage\"><img src=imgs/ico_edit.gif width=16 height=16 alt=\"modifica\" border=0></a></td>
				   <td width=20px bgcolor=\"#DFDFDF\">";
				   if($titolo !="Home page")
				    $content .= "<a href=\"content.php?op=del_page&idpage=$idpage&currentpage=$currentpage&percorso=".urlencode($percorso)."\" onclick=\"return confirm('Sei sicuro di voler eliminare la pagina $titolo ?');\"><img src=imgs/ico_delete.gif width=16 height=16 alt=\"elimina\" border=0></a>";
				   else
				    $content .= "&nbsp;";	
				   $content .= "</td>
				   <td width=20>$linkp</td>";
				   $content .= "</tr>";
				 }
				 $content .= "</table></td></tr>\n";
				 //spazio
				 $content .= "<tr><td colspan=2>&nbsp;</td></tr>\n";
		if(isset($idpages) && $idpages != "") {
		//pagina di modifica content
		  $newPage = new content($idpages);
		  $titolo = $newPage->titolo;
		  $contenuto = $newPage->contenuto;
		  $tagtitle = $newPage->tagtitle;
		  $tagkey = $newPage->tagkey;
		  $tagdesc = $newPage->tagdesc;
		  $metatitle = $newPage->metatitle;
		  $metakey = $newPage->metakey;
		  $metadesc = $newPage->metadesc;
		  $hidden = $newPage->hidden;
		  $hidden_id = "<input type=hidden name=\"idpage\" value=\"$idpages\"><input type=hidden name='op' value='update_page'>
		  <input type=hidden name=currentpage value=\"content.php?idtopic=$idtopics&op=content&percorso=".urlencode($percorso)."\">
		  <input type=\"hidden\" name=\"percorso\" value=\"".urlencode($percorso)."\">";
		  $button = "- <a href=\"javascript:document.addpageform.reset();\"><img src=\"imgs/reset.gif\" width=16 height=16 border=0 alt=\"Reimposta\">&nbsp;&nbsp;Annulla modifiche</a>";
		  $onload = "showHide('addpage')";
		}  else  {
		  	if($idtopics != "")  {
				 //tasto aggiungi voce
				 $content .= "<tr><td class=content colspan=2><a class=content href=javascript:; onclick=\"showHide('addsezione2');\">Aggiungi voce</a></td></tr>
				 <tr><td colspan=2 class=content><div id=\"addsezione2\"><center>Aggiungi voce</center><br>
            <form name=addtopic_s action=content.php method=post>
		 Nome:<br><input type=text size=35 name=nome_s>&nbsp;&nbsp;
		 <input type='hidden' name='op' value='save'>
		 <input type=hidden name=idfather value=\"$idtopics\">
		 <input type=hidden name=\"percorso\" value='".urlencode($percorso)."'>
		 <input type=hidden name=\"currentpage\" value='".$currentpage."'><input type=image src=\"imgs/ico_save.gif\" title=Salva onClick=\"return control_topic_s();\" width=16 height=16><br><a href=\"#\" onClick=\"showHide('addsezione2');\"><img src=\"imgs/ico_delete.gif\" width=\"16\" height=\"16\" border=0 alt=\"Chiudi\" align=\"right\"></a></form></div>
</td></tr>";
		 		//tasto aggiungi pagina
				$content .= "<tr><td class=content colspan=2><a class=content href=javascript:; onclick=\"showHide('addpage');\">Aggiungi pagina web</a></td></tr>";
		  $hidden_id = "<input type='hidden' name='op' value='save_page'><input type=\"hidden\" name=\"currentpage\" value=\"$currentpage\">
		  <input type=\"hidden\" name=\"percorso\" value=\"".urlencode($percorso)."\">";
		  }
		}
			$content .="<tr><td colspan=2 class=content><div id=\"addpage\">
            <form name=addpageform action=content.php method=post>
			<table width=700px cellpadding=3 cellspacing=0 class=content bgcolor=#CCCCCC>
		 <tr><td width=50px align=right>Titolo:<td width=650><input type=text size=50 name=titolo value=\"$titolo\"></td></tr>
		 <tr><td colspan=2>Contenuto:<br>";
		 //start editor
		$oFCKeditor = new FCKeditor('contenuto');
		$oFCKeditor->Value = "$contenuto";
		$content .= $oFCKeditor->Create(); 
		 $content .= "</td></tr>
		 <tr>
		 <td align=right valign=top><a href=javascript:; onclick=\"showHide('meta');\"><img src=\"imgs/ico_indicizzazione.gif\" border=0></a></td>
		 <td><a href=javascript:; onclick=\"showHide('meta');\">Indicizza questa pagina</a><div id=meta style=\"visibility:hidden; display:none;\">
		 <table width=100% class=content border=0 cellpadding=2>
		   <tr>
		    <td width=100 align=right valign=top>Titolo pagina:<br>Tag &lt;title&gt;</td>
			<td valign=top><textarea name=tagtitle rows=5 cols=120>$tagtitle</textarea></td>
		   </tr>
		   <tr>
		    <td width=100 align=right valign=top>Parole chiave:<br>Meta-tag &lt;keywords&gt;</td>
			<td valign=top><textarea name=tagkey rows=5 cols=120>$tagkey</textarea></td>
		   </tr>
		   <tr>
		    <td width=100 align=right valign=top>Descrizione pagina:<br>Meta-tag &lt;description&gt;</td>
			<td valign=top><textarea name=tagdesc rows=5 cols=120>$tagdesc</textarea></td>
		   </tr>
		   <tr>
		    <td width=100 align=right valign=top>Titolo documento:<br>Meta-tag &lt;title&gt;</td>
			<td valign=top><textarea name=metatitle rows=5 cols=120>$metatitle</textarea></td>
		   </tr>
		   <tr>
		    <td width=100 align=right valign=top>Frasi documento:<br>Meta-tag &lt;Keyphrase&gt;</td>
			<td valign=top><textarea name=metakey rows=5 cols=120>$metakey</textarea></td>
		   </tr>
		   <tr>
		    <td width=100 align=right valign=top>Descrizione:<br>Meta-tag &lt;http-equiv=\"description\"&gt;</td>
			<td valign=top><textarea name=metadesc rows=5 cols=120>$metadesc</textarea></td>
		   </tr>
		   <tr>
		    <td width=100 align=right valign=top>Testo nascosto:<br><!-- commento HTML --></td>
			<td valign=top><textarea name=hidden rows=5 cols=120>$hidden</textarea></td>
		   </tr>
		 </table>
		</div>
	   </td>
	  </tr>
	  <tr><td colspan=2>&nbsp;</td></tr>
	  <tr><td colspan=2>
		 $hidden_id
		 <input type=hidden name=idtopic value=\"$idtopics\">
		 <input type=image src=\"imgs/ico_save.gif\" title=Salva onClick=\"return control_page();\" width=16 height=16>&nbsp;&nbsp;<a class=content href=\"javascript:document.addpageform.submit();\">Salva</a> $button</td></tr></table></div></td></tr></form>";
				$content .= "</table>"; 
			  break;
			  
			  case "save":
			   if($idfathers == "")
			    $idfathers = 0;
			   $newTopic = new topic('',$nomes,$idfathers,$id_user);
			   $error = $newTopic->save();
			   if($error == "0")
			    header("Location:$currentpage");
			   else  {
			     $content = $error;
				}	    	
			  break;
			  
			  case "up":
			    $newTopic = new topic($idtopics);
				$error = $newTopic->up();
				if($error == "0")
				 header("Location:$currentpage");
				else  {
				  $content = $error;
				}				  
			  break;
			  
			  case "down":
			    $newTopic = new topic($idtopics);
				$error = $newTopic->down();
				if($error == "0")
				 header("Location:$currentpage");
				else  {
				  $content = $error;
				}				  
			  break;
			  
			  case "update":
			    $newTopic = new topic($idtopicupd);
				$error = $newTopic->update($nomeupd);
				if($error == "0")
				 header("Location:$currentpage");
				else  {
				  $content = $error;
				} 
			  break;
			  			  
			  case "del":
			    $newTopic = new topic($idtopics);
				$error = $newTopic->delete();
				if($error == "0")
				 header("Location:$currentpage");
				else  {
				  $content = $error;
				} 
			  break;
			  
			  case "save_page":
			    $newPage = new content('',$idtopics,$titolos,$contenutos,$tagtitles,$tagkeys,$tagdescs,$metatitles, $metakeys, $metadescs, $hiddens,$id_user);
				$error = $newPage->save();
				if($error == "0")
				 header("Location:content.php?idtopic=$idtopics&op=content&percorso=$percorso");
				else  {
				  $content = $error;
				} 
			  break;
			  
			  case "update_page":
			    $newPage = new content($idpages);
				$error = $newPage->update($titolos,$idtopics,$contenutos,$tagtitles,$tagkeys,$tagdescs,$metatitles, $metakeys, $metadescs, $hiddens);
				if($error == "0")
				 header("Location:content.php?idtopic=$idtopics&op=content&percorso=$percorso");
				else  {
				  $content = $error;
				} 
			  break;
			  
			  case "up_page":
			    $newPage = new content($idpages);
				$error = $newPage->up();
				if($error == "0")
				 header("Location:content.php?idtopic=$newPage->idtopic&op=content&percorso=".urlencode($percorso));
				else  {
				  $content = $error;
				}				  			    
			  break;
			  			  
			  case "down_page":
			    $newPage = new content($idpages);
				$error = $newPage->down();
				if($error == "0")
				 header("Location:content.php?idtopic=$newPage->idtopic&op=content&percorso=".urlencode($percorso));
				else  {
				  $content = $error;
				}				  			    
			  break;

			  case "disattiva":
			    $newPage = new content($idpages);
				$error = $newPage->disattiva();
				if($error == "0")
				 header("Location:content.php?idtopic=$newPage->idtopic&op=content&percorso=".urlencode($percorso));
				else  {
				  $content = $error;
				}				  			    
			  break;
			  
			  case "pubblica":
			    $newPage = new content($idpages);
				$error = $newPage->pubblica();
				if($error == "0")
				 header("Location:content.php?idtopic=$newPage->idtopic&op=content&percorso=".urlencode($percorso));
				else  {
				  $content = $error;
				}				  			    
			  break;

			  case "del_page":
			    $newPage = new content($idpages);
				$error = $newPage->delete();
				if($error == "0")
				 header("Location:content.php?idtopic=$newPage->idtopic&op=content&percorso=".urlencode($percorso));
				else  {
				  $content = $error;
				} 
			  break;

			  default:
			  if($num_topic == 0)  {
				  $content = "<table width=100% class=content cellpadding=3><form name=addtopic action=content.php method=post><tr><td class=tbtit>Aggiungi sezione principale</td></tr>
				  <tr><td class=content width=100%>Nome:&nbsp;<input type=text size=50 name=nome>&nbsp;&nbsp;&nbsp;<input type='hidden' name='op' value='save'>
				  <input type=\"hidden\" name=\"currentpage\" value=\"$currentpage\">
				  <input type=image src=\"imgs/ico_save.gif\" title=Salva onClick=\"return control_topic();\" width=16 height=16></td></tr></form></table>";	}			
			  break;
            }
			//$menusx .= "</table>";
?>
<html><!-- InstanceBegin template="/Templates/moduli.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Modulo Pagine Web</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" -->
<script type="text/JavaScript">
<!--
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  var dis;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) {
	   obj=obj.style; 
	   if(v == 'show')  {
	     v = 'visible';
		 dis = 'block';
	   }
	   if(v == 'hide')  {
	     v = 'hidden';
		 dis = 'none';	 
	   }
	 }  
    obj.visibility = v; 
	obj.display = dis;
	}
}

function showHide(id, idsezione, nome)  {
	var obj;
	obj=MM_findObj(id);
	if(obj.style.visibility=='visible')
	 MM_showHideLayers(id,'','hide');
	else  {
	 MM_showHideLayers(id,'','show');
	 document.addtopic.currentpage.value=location.href;
	 //document.modtopic.page.value=location.href;	
	 if(id == "editSezione")  {
	  document.modtopic.nomeupd.value=nome;
	  document.modtopic.idtopicupd.value=idsezione;
	  document.modtopic.nomeupd.focus();
	 }
	}
}
//-->
</script>
<!-- InstanceEndEditable -->
<link href="style/style.css" rel="stylesheet" type="text/css">
<script type="text/JavaScript">
<!--
<?=$javascript?>

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  var dis;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) {
	   obj=obj.style; 
	   if(v == 'show')  {
	     v = 'visible';
		 dis = 'block';
	   }
	   if(v == 'hide')  {
	     v = 'hidden';
		 dis = 'none';	 
	   }
	 }  
    obj.visibility = v; 
	obj.display = dis;
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('imgs/icons/pag_web-b.gif','imgs/icons/info_utente-b.gif','imgs/icons/prodotti-b.gif','imgs/icons/newsletter-b.gif','imgs/icons/news-b.gif','imgs/icons/gest_banner-b.gif','imgs/icons/utenti-b.gif','imgs/icons/configurazione-b.gif','imgs/icons/kw-b.gif'); <?=$onload?>">
<!-- ImageReady Slices (gestione.psd - Slices: 02, 03, 04, 06, 07, 08, 09, 10, 11, 12) -->
<!-- End ImageReady Slices -->
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="40" height="177" background="imgs/bkgSx.gif">&nbsp;</td>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="552" background="imgs/gestione_02.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="360"><img src="imgs/spacer20.gif" width="360" height="73"></td>
            <td><table width="100%" height="73" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td height="5"><img src="imgs/spacer20.gif" width="45" height="5"></td>
              </tr>
              <tr>
                <td align="left" valign="middle" class="tit01"><!-- InstanceBeginEditable name="user" --><?=$username?><!-- InstanceEndEditable --></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
        <td background="imgs/gestione_03.gif">&nbsp;</td>
        <td width="221"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="imgs/gestione_04.gif" width="221" height="17" alt=""></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="57"><a href="gestione.php?logout=1"><img src="imgs/gestione_06.gif" alt="Logout" width="57" height="51" border="0"></a></td>
                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td><a href="mailto:info@media-tek.it"><img src="imgs/gestione_07.gif" alt="" width="164" height="25" border="0"></a></td>
                  </tr>
                  <tr>
                    <td><a href="#"><img src="imgs/gestione_08.gif" alt="" width="164" height="26" border="0"></a></td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td><img src="imgs/gestione_09.gif" width="221" height="5" alt=""></td>
          </tr>
        </table></td>
      </tr>
    </table>
      <table width="100%" height="104" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="678" background="imgs/gestione_10.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="203"><table width="203" height="104" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td><img src="imgs/spacer20.gif" width="203" height="65"></td>
                </tr>
                <tr>
                  <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="45"><img src="imgs/spacer20.gif" width="45" height="39"></td>
                      <td><table width="100%" height="39" border="0" cellpadding="5" cellspacing="0">
                        <tr>
                          <td align="left" valign="middle" class="module"><!-- InstanceBeginEditable name="module" --><?=$module.$currentlang?><!-- InstanceEndEditable --></td>
                        </tr>
                      </table></td>
                    </tr>
                  </table></td>
                </tr>
              </table></td>
              <td><table width="475" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="50"><img src="imgs/spacer20.gif" width="50" height="104" alt=""></td>
                  <td align="left" valign="bottom">
				  <? if($level!="VBL")  { ?>
				  <table border="0" cellspacing="0" cellpadding="2"><tr><?
	if($level=="admin")  {
?><td width="58"><a href="gestione.php?module=content" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('pages','','imgs/icons/pag_web-b.gif',1)"><img src="imgs/icons/pag_web.gif" alt="Pagine web" name="pages" width="58" height="69" border="0"></a></td><td width="58"><a href="gestione.php?module=newsletter" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Newsletter','','imgs/icons/newsletter-b.gif',1)"><img src="imgs/icons/newsletter.gif" alt="Newsletter" name="Newsletter" width="58" height="69" border="0"></a></td><?
	}
	if($level=="admin")  {
?><td width="58"><a href="gestione.php?module=banner" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('banner','','imgs/icons/gest_banner-b.gif',1)"><img src="imgs/icons/gest_banner.gif" alt="Gestione Banner" name="banner" width="58" height="69" border="0"></a></td><?
	}
?><td width="58"><a href="gestione.php?module=prodotti"><img src="imgs/icons/prodotti.gif" alt="Pagine Web" name="pagine" width="58" height="69" border="0" id="pagine" onMouseOver="MM_swapImage('pagine','','imgs/icons/prodotti-b.gif',1)" onMouseOut="MM_swapImgRestore()"></a></td>
</tr></table>
<? } ?>
</td>
				</tr>
              </table></td>
            </tr>
          </table></td>
          <td valign="bottom" background="imgs/gestione_11.gif"><?
	if($level=="admin")  {
?><table cellpadding="2" cellspacing="0">
		    <tr>
			  <td width="58"><a href="gestione.php?module=webuser" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('webutente','','imgs/icons/utenti-b.gif',1)"><img src="imgs/icons/utenti.gif" name="webutente" width="58" height="69" border="0"></a></td>
			  <td width="58"><a href="gestione.php?module=user" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Utente','','imgs/icons/info_utente-b.gif',1)"><img src="imgs/icons/info_utente.gif" name="Utente" width="58" height="69" border="0"></a></td>
			  <td width="20" valign="middle">
			   </td>			  
			</tr>
		   </table><?
		   } else {
?>&nbsp;<?
}
		   ?></td>
          <td width="95"><img src="imgs/gestione_12.gif" width="95" height="104" alt=""></td>
        </tr>
      </table>
    </td>
    <td width="40" background="imgs/bkgDx.gif">&nbsp;</td>
  </tr>
  <tr>
    <td background="imgs/bkgSx.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F6F6F6"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="203" align="left" valign="top" bgcolor="#DFDFDF" class="menusx"><!-- InstanceBeginEditable name="menuSx" --><?=$menusx?>
		<div id="addsezione">
            <form name=addtopic action=content.php method=post>
		 Nome:<br><input type=text size=35 name=nome>&nbsp;&nbsp;
		 <input type='hidden' name='op' value='save'>
		 <input type="hidden" name="currentpage">
		 <input type="hidden" name="percorso" value="<?=urlencode($percorso)?>">
		 <input type="hidden" name="currentpage" value="<?=$currentpage?>"><input type=image src="imgs/ico_save.gif" title=Salva onClick="return control_topic();" width=16 height=16><br><a href="#" onClick="showHide('addsezione');"><img src="imgs/ico_delete.gif" width="16" height="16" border=0 alt="Chiudi" align="right"></a></form></div>
		 <table class=menusx width=100% border=0>
							<tr>
							  <td valign=middle width=30 height=30><a class=menusx href=gestione.php><img src="imgs/ico_back.gif" width=30 height=30 alt=Principale border=0></a></td><td align=left valign=middle><a class=menusx href=gestione.php>Torna alla pagina principale</a></td></tr></table>
				 

        <!-- InstanceEndEditable --></td>
        <td align="left" valign="top" bgcolor="#EFEFEF" class="content"><!-- InstanceBeginEditable name="content" --><?=$content?>
          <div id="editSezione"><center>Area modifica</center><br>
<form name=modtopic action="content.php" method=post>
		 Nome:<br><input type=text size=35 name="nomeupd">&nbsp;&nbsp;
		 <input type='hidden' name='op' value='update'>
		 <input type="hidden" name="idtopicupd">
		 <input type="hidden" name="percorso" value="<?=urlencode($percorso)?>">
		 <input type="hidden" name="currentpage" value="<?=$currentpage?>"><input type=image src="imgs/ico_save.gif" title=Salva width=16 height=16 onClick="showHide('editSezione');"><br><a href="#" onClick="showHide('editSezione');"><img src="imgs/ico_delete.gif" width="16" height="16" border=0 alt="Chiudi" align="right"></a></form></div>
          <!-- InstanceEndEditable --></td>
      </tr>
    </table>
      <table width="100%" height="50" border="0" cellpadding="5" cellspacing="0">
        <tr>
          <td background="imgs/gestione_03.gif" bgcolor="#F6F6F6" class="copy"><p>2006&copy; Gestione moduli dinamici - release 1.2 - Powered by Media-tek </p></td>
        </tr>
      </table></td>
    <td background="imgs/bkgDx.gif">&nbsp;</td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>
<?
       break;

       case AUTH_NOT_LOGGED:
        header("Location:index.html");
       break;
}
?>